POV-Ray : Newsgroups : povray.newusers : how to make a 2D image from 3D image : Re: how to make a 2D image from 3D image Server Time
28 Jul 2024 16:26:07 EDT (-0400)
  Re: how to make a 2D image from 3D image  
From: vinhphunguyen
Date: 13 Jun 2008 05:50:01
Message: <web.4852425d5fabdd0ab979a58c0@news.povray.org>
Dear Chris,

I just found one case the code does not work well. Imagine that, taking your
simplified example, there is another layered sphere behind this one along z
axis (so that the plane z = 0 does not cut it) and shifted some units along x
axis. In this case, the slice image should not contain the second sphere.

Here is the code

camera {location <0,0,-3.5> look_at 0}
light_source {   <0,0 ,-100>, rgb 1}

#declare grain1 = union{
  difference {
    sphere{<0,0,0>, 0.3 pigment {color rgb <1,0,0>}}
    sphere{<0,0,0>, 0.2 pigment {color rgb <0,1,0>}}
  }
  difference {
    sphere{<0,0,0>, 0.2 pigment {color rgb <0,1,0>}}
    sphere{<0,0,0>, 0.1 pigment {color rgb <0,0,1>}}
  }
  sphere{<0,0,0>, 0.1 pigment {color rgb <0,0,1>}}
}

#declare grain2 = union{
  difference {
    sphere{<2,0,1>, 0.3 pigment {color rgb <1,0,0>}}
    sphere{<2,0,1>, 0.2 pigment {color rgb <0,1,0>}}
  }
  difference {
    sphere{<2,0,1>, 0.2 pigment {color rgb <0,1,0>}}
    sphere{<2,0,1>, 0.1 pigment {color rgb <0,0,1>}}
  }
  sphere{<2,0,1>, 0.1 pigment {color rgb <0,0,1>}}
}

#declare grains = union{
  object{grain1}
  object{grain2}
}

difference {
  object {grains}
  plane {z,0}
  cutaway_textures
}

------------------

I switched from difference operation to intersection, then the second sphere
disappeared but the first sphere showed only the outermost layer.

Could you help me to figure out this problem please?

Thanks a lot for your help.

Vinh Phu


"Chris B" <nom### [at] nomailcom> wrote:
> "vinhphunguyen" <nvi### [at] gmailcom> wrote in message
> news:web.48513efe78241c82b979a58c0@news.povray.org...
> > Dear all,
> >
> > I would like to generate images like the ones in the right column at this
> > link
> > http://www.micthemodel.org/pages/examples.html (Sorry but I can not post
> > attachment).
> >
> > These images are in fact 2D slices of a 3D image that is a cube containing
> > a set
> > of layered spheres. A layered sphere is a set of concentric spheres of
> > different
> > colors. In my program (in fact, this is the visualisation of cement
> > hydration
> > simulation), I have the coordinate and radius of the spheres and the color
> > as
> > well.
> >
> > ...
> >
> > With this one, I did see the spheres but just one color CYAN.
> >
>
> I think you need to do a couple of things.
>
> Firstly, when you slice through, use the 'difference' CSG operation with the
> 'cutaway_textures' keyword, so that the slices through the objects retain
> their original textures.
>
> Secondly you need to difference the second largest sphere from the largest,
> the 3rd largest from the second largest etc. Otherwise, when you slice
> through the union of concentric spheres the section through the smaller
> spheres produce concurrent surfaces with the larger spheres and most of the
> surfaces won't display the colour you want. In fact you'll only get the
> colour you want displaying properly for the outermost object.
>
> Here's a simplified example:
>
> camera {location <0,0,-1> look_at 0}
> light_source {   <0,0 ,-100>, rgb 1}
>
> #declare MySpheres = union{
>   difference {
>     sphere{<0,0,0>, 0.3 pigment {color rgb <1,0,0>}}
>     sphere{<0,0,0>, 0.2 pigment {color rgb <0,1,0>}}
>   }
>   difference {
>     sphere{<0,0,0>, 0.2 pigment {color rgb <0,1,0>}}
>     sphere{<0,0,0>, 0.1 pigment {color rgb <0,0,1>}}
>   }
>   sphere{<0,0,0>, 0.1 pigment {color rgb <0,0,1>}}
> }
>
> difference {
>   object {MySpheres}
>   plane {z,0}
>   cutaway_textures
> }
>
> Regards,
> Chris B.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.